package cn.iocoder.yudao.module.agri.dal.mysql.farmmodel;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.agri.dal.dataobject.farmmodel.FarmModelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.agri.controller.admin.farmmodel.vo.*;

/**
 * 种养模型 Mapper
 *
 * @author 广东小蜂
 */
@Mapper
public interface FarmModelMapper extends BaseMapperX<FarmModelDO> {

    default PageResult<FarmModelDO> selectPage(FarmModelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FarmModelDO>()
                .eqIfPresent(FarmModelDO::getId, reqVO.getId())
                .likeIfPresent(FarmModelDO::getModelName, reqVO.getModelName())
                .likeIfPresent(FarmModelDO::getCrop, reqVO.getCrop())
                .eqIfPresent(FarmModelDO::getCycle, reqVO.getCycle())
                .eqIfPresent(FarmModelDO::getBeginMonth, reqVO.getBeginMonth())
                .likeIfPresent(FarmModelDO::getArea, reqVO.getArea())
                .eqIfPresent(FarmModelDO::getModelType, reqVO.getModelType())
                .eqIfPresent(FarmModelDO::getShare, reqVO.getShare())
                .orderByDesc(FarmModelDO::getId));
    }

    default List<FarmModelDO> selectList(FarmModelExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FarmModelDO>()
                .eqIfPresent(FarmModelDO::getId, reqVO.getId())
                .likeIfPresent(FarmModelDO::getModelName, reqVO.getModelName())
                .likeIfPresent(FarmModelDO::getCrop, reqVO.getCrop())
                .eqIfPresent(FarmModelDO::getCycle, reqVO.getCycle())
                .eqIfPresent(FarmModelDO::getBeginMonth, reqVO.getBeginMonth())
                .likeIfPresent(FarmModelDO::getArea, reqVO.getArea())
                .eqIfPresent(FarmModelDO::getModelType, reqVO.getModelType())
                .eqIfPresent(FarmModelDO::getShare, reqVO.getShare())
                .orderByDesc(FarmModelDO::getId));
    }

}
